from __future__ import print_function
import logging

import grpc
import IkfastServer_pb2_grpc
import IkfastServer_pb2

def run():
    with grpc.insecure_channel('localhost:50051') as channel:
        stub = IkfastServer_pb2_grpc.IkfastStub(channel)

        test = [0.04071115329861641, -0.9987091422080994, 0.030375992879271507, 0.4720008969306946,
                -0.998744547367096, -0.04156302660703659, -0.027960671111941338, 0.12648242712020874,
                0.029187096282839775, -0.029199546203017235, -0.9991474151611328, 0.4345116913318634]
        poseList_a = [IkfastServer_pb2.Posture(matrix=test, id=999)]
        post_list = IkfastServer_pb2.RequestBody(poseList=poseList_a, size=len(poseList_a))
        response = stub.ComputeIk(post_list)
        response_result = response.result
        for result in response_result:
            print("result id is :%s", result.id)
            angles = result.angles
            for angle in angles:
                double_list = []
                for ax in angle.ax:
                    double_list.append(ax)
                print(double_list)

if __name__ == '__main__':
    logging.basicConfig()
    run()